home *** CD-ROM | disk | FTP | other *** search
- Path: nuhou.aloha.net!coconut!usenet
- From: Dave Carien <davec@hawaii.edu>
- Newsgroups: comp.lang.c
- Subject: Re: Standard question - pointer initialization
- Date: Thu, 14 Mar 1996 18:38:29 -0800
- Organization: KnightSoft/Voyager
- Message-ID: <3148D825.945@hawaii.edu>
- References: <4hk9un$906@hammer.msfc.nasa.gov> <4hl6rr$nde@news.xs4all.nl>
- <313E6028.1C19@ix.netcom.com> <4hnpsl$g8c@hacgate2.hac.com>
- <4hq9hsINN998@keats.ugrad.cs.ubc.ca> <4i7cgn$5da@baygull.rtd.com> <TANMOY.96Mar13184413@qcd.lanl.gov>
- NNTP-Posting-Host: dialup61.aloha.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- Tanmoy Bhattacharya wrote:
- >
- > In article <4i7cgn$5da@baygull.rtd.com>
- > collins@RTD.COM (Ronald Collins) writes:
- > <snip>
- > RC: : Also note that NULL is just a macro that stands for the value zero (often
- > RC: : accompanied by a cast to void *). In assigning default initialization values to
- > RC: : static variables, the compiler couldn't care less that there is a pre-processor
- > RC: : macro called NULL. NULL can never be anything other than zero in a
- > RC: : standard-conforming implementation of the C language.
- > RC:
- > RC: This may be true on _your_ implementation, but nothing in the standard
- > RC: requires the NULL value to be numerically 0.
- > RC:
- > RC: Please read the FAQ before posting on the subject again.
- >
- > Confusion reigns!
- >
- > NULL is a macro which is defined in a number of standard headers. It
- > is guaranteed to be an integral constant (roughly, compile time
- > integral constant which does not depend on floating ot pointer
- > arithmetic) with the value 0; or such a quantity cast to (void*).
- >
- > Thus it could be 0, (1-1), (void*)0, __builtin_null (with a previous
- > enum __builtin_tag { __builtin_null }; explicit or assumed), or an
- > infinity of other forms. However, informally, all of these are zeros.
- >
- > In a context where the compiler _knows_ that a pointer is required,
- > the compiler shall automatically converted all integral constant zeros
- > to a null pointer. The representation of this null pointer may
- > actually depend on its type, and has no relation to zero. This is what
- > the FAQ file was trying to explain.
-
-
- I was under the impression that NULL was a pointer type and to convert it
- to a char type it you would need to do something such as:
-
- (char)NULL
-
- Of course it would be wiser to use '\0', or just 0 for an int typecast.
- If I'm wrong I'm sorry.
-
- davec@hawaii.edu
-